What is @aws-sdk/client-pinpoint?
@aws-sdk/client-pinpoint is an AWS SDK for JavaScript package that allows developers to interact with the Amazon Pinpoint service. Amazon Pinpoint is a flexible and scalable outbound and inbound marketing communications service. It enables you to engage with your customers by sending them targeted messages through multiple channels, such as email, SMS, push notifications, and voice messages.
What are @aws-sdk/client-pinpoint's main functionalities?
Send Email
This feature allows you to send an email using Amazon Pinpoint. The code sample demonstrates how to configure and send an email message to a recipient.
const { PinpointClient, SendMessagesCommand } = require('@aws-sdk/client-pinpoint');
const client = new PinpointClient({ region: 'us-west-2' });
const params = {
ApplicationId: 'your-application-id',
MessageRequest: {
Addresses: {
'recipient@example.com': {
ChannelType: 'EMAIL'
}
},
MessageConfiguration: {
EmailMessage: {
SimpleEmail: {
Subject: { Data: 'Test Email' },
HtmlPart: { Data: '<h1>Hello</h1><p>This is a test email.</p>' },
TextPart: { Data: 'Hello, This is a test email.' }
}
}
}
}
};
const run = async () => {
try {
const data = await client.send(new SendMessagesCommand(params));
console.log('Success', data);
} catch (err) {
console.error('Error', err);
}
};
run();
Send SMS
This feature allows you to send an SMS message using Amazon Pinpoint. The code sample demonstrates how to configure and send an SMS message to a recipient.
const { PinpointClient, SendMessagesCommand } = require('@aws-sdk/client-pinpoint');
const client = new PinpointClient({ region: 'us-west-2' });
const params = {
ApplicationId: 'your-application-id',
MessageRequest: {
Addresses: {
'+1234567890': {
ChannelType: 'SMS'
}
},
MessageConfiguration: {
SMSMessage: {
Body: 'This is a test SMS message.',
MessageType: 'TRANSACTIONAL'
}
}
}
};
const run = async () => {
try {
const data = await client.send(new SendMessagesCommand(params));
console.log('Success', data);
} catch (err) {
console.error('Error', err);
}
};
run();
Create Segment
This feature allows you to create a segment in Amazon Pinpoint. The code sample demonstrates how to define and create a segment based on specific criteria.
const { PinpointClient, CreateSegmentCommand } = require('@aws-sdk/client-pinpoint');
const client = new PinpointClient({ region: 'us-west-2' });
const params = {
ApplicationId: 'your-application-id',
WriteSegmentRequest: {
Name: 'TestSegment',
Dimensions: {
Demographic: {
Channel: {
Values: ['EMAIL'],
DimensionType: 'INCLUSIVE'
}
}
}
}
};
const run = async () => {
try {
const data = await client.send(new CreateSegmentCommand(params));
console.log('Success', data);
} catch (err) {
console.error('Error', err);
}
};
run();
Other packages similar to @aws-sdk/client-pinpoint
sendgrid
SendGrid is a cloud-based service that provides email delivery and marketing campaigns. It offers similar functionalities to Amazon Pinpoint's email capabilities, including sending transactional and marketing emails, managing lists, and tracking email performance. However, SendGrid is focused solely on email, whereas Amazon Pinpoint supports multiple communication channels.
twilio
Twilio is a cloud communications platform that allows developers to build and manage communication channels such as SMS, voice, and video. Twilio offers similar functionalities to Amazon Pinpoint's SMS and voice capabilities. Twilio is known for its ease of use and extensive API documentation, but it does not provide the same level of integration with other AWS services as Amazon Pinpoint.
mailchimp
Mailchimp is a marketing automation platform and email marketing service. It offers functionalities similar to Amazon Pinpoint's email and campaign management features. Mailchimp provides tools for creating email campaigns, managing subscriber lists, and analyzing campaign performance. Unlike Amazon Pinpoint, Mailchimp is primarily focused on email marketing and does not support other communication channels like SMS or push notifications.
@aws-sdk/client-pinpoint
Description
AWS SDK for JavaScript Pinpoint Client for Node.js, Browser and React Native.
Doc Engage API - Amazon Pinpoint API
Installing
To install this package, simply type add or install @aws-sdk/client-pinpoint
using your favorite package manager:
npm install @aws-sdk/client-pinpoint
yarn add @aws-sdk/client-pinpoint
pnpm add @aws-sdk/client-pinpoint
Getting Started
Import
The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the PinpointClient
and
the commands you need, for example ListTemplatesCommand
:
const { PinpointClient, ListTemplatesCommand } = require("@aws-sdk/client-pinpoint");
import { PinpointClient, ListTemplatesCommand } from "@aws-sdk/client-pinpoint";
Usage
To send a request, you:
- Initiate client with configuration (e.g. credentials, region).
- Initiate command with input parameters.
- Call
send
operation on client with command object as input. - If you are using a custom http handler, you may call
destroy()
to close open connections.
const client = new PinpointClient({ region: "REGION" });
const params = {
};
const command = new ListTemplatesCommand(params);
Async/await
We recommend using await
operator to wait for the promise returned by send operation as follows:
try {
const data = await client.send(command);
} catch (error) {
} finally {
}
Async-await is clean, concise, intuitive, easy to debug and has better error handling
as compared to using Promise chains or callbacks.
Promises
You can also use Promise chaining
to execute send operation.
client.send(command).then(
(data) => {
},
(error) => {
}
);
Promises can also be called using .catch()
and .finally()
as follows:
client
.send(command)
.then((data) => {
})
.catch((error) => {
})
.finally(() => {
});
Callbacks
We do not recommend using callbacks because of callback hell,
but they are supported by the send operation.
client.send(command, (err, data) => {
});
v2 compatible style
The client can also send requests using v2 compatible style.
However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post
on modular packages in AWS SDK for JavaScript
import * as AWS from "@aws-sdk/client-pinpoint";
const client = new AWS.Pinpoint({ region: "REGION" });
try {
const data = await client.listTemplates(params);
} catch (error) {
}
client
.listTemplates(params)
.then((data) => {
})
.catch((error) => {
});
client.listTemplates(params, (err, data) => {
});
Troubleshooting
When the service returns an exception, the error will include the exception information,
as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
}
Getting Help
Please use these community resources for getting help.
We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
To test your universal JavaScript code in Node.js, browser and react-native environments,
visit our code samples repo.
Contributing
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-pinpoint
package is updated.
To contribute to client you can check our generate clients scripts.
License
This SDK is distributed under the
Apache License, Version 2.0,
see LICENSE for more information.
Client Commands (Operations List)
CreateApp
Command API Reference / Input / Output
CreateCampaign
Command API Reference / Input / Output
CreateEmailTemplate
Command API Reference / Input / Output
CreateExportJob
Command API Reference / Input / Output
CreateImportJob
Command API Reference / Input / Output
CreateInAppTemplate
Command API Reference / Input / Output
CreateJourney
Command API Reference / Input / Output
CreatePushTemplate
Command API Reference / Input / Output
CreateRecommenderConfiguration
Command API Reference / Input / Output
CreateSegment
Command API Reference / Input / Output
CreateSmsTemplate
Command API Reference / Input / Output
CreateVoiceTemplate
Command API Reference / Input / Output
DeleteAdmChannel
Command API Reference / Input / Output
DeleteApnsChannel
Command API Reference / Input / Output
DeleteApnsSandboxChannel
Command API Reference / Input / Output
DeleteApnsVoipChannel
Command API Reference / Input / Output
DeleteApnsVoipSandboxChannel
Command API Reference / Input / Output
DeleteApp
Command API Reference / Input / Output
DeleteBaiduChannel
Command API Reference / Input / Output
DeleteCampaign
Command API Reference / Input / Output
DeleteEmailChannel
Command API Reference / Input / Output
DeleteEmailTemplate
Command API Reference / Input / Output
DeleteEndpoint
Command API Reference / Input / Output
DeleteEventStream
Command API Reference / Input / Output
DeleteGcmChannel
Command API Reference / Input / Output
DeleteInAppTemplate
Command API Reference / Input / Output
DeleteJourney
Command API Reference / Input / Output
DeletePushTemplate
Command API Reference / Input / Output
DeleteRecommenderConfiguration
Command API Reference / Input / Output
DeleteSegment
Command API Reference / Input / Output
DeleteSmsChannel
Command API Reference / Input / Output
DeleteSmsTemplate
Command API Reference / Input / Output
DeleteUserEndpoints
Command API Reference / Input / Output
DeleteVoiceChannel
Command API Reference / Input / Output
DeleteVoiceTemplate
Command API Reference / Input / Output
GetAdmChannel
Command API Reference / Input / Output
GetApnsChannel
Command API Reference / Input / Output
GetApnsSandboxChannel
Command API Reference / Input / Output
GetApnsVoipChannel
Command API Reference / Input / Output
GetApnsVoipSandboxChannel
Command API Reference / Input / Output
GetApp
Command API Reference / Input / Output
GetApplicationDateRangeKpi
Command API Reference / Input / Output
GetApplicationSettings
Command API Reference / Input / Output
GetApps
Command API Reference / Input / Output
GetBaiduChannel
Command API Reference / Input / Output
GetCampaign
Command API Reference / Input / Output
GetCampaignActivities
Command API Reference / Input / Output
GetCampaignDateRangeKpi
Command API Reference / Input / Output
GetCampaigns
Command API Reference / Input / Output
GetCampaignVersion
Command API Reference / Input / Output
GetCampaignVersions
Command API Reference / Input / Output
GetChannels
Command API Reference / Input / Output
GetEmailChannel
Command API Reference / Input / Output
GetEmailTemplate
Command API Reference / Input / Output
GetEndpoint
Command API Reference / Input / Output
GetEventStream
Command API Reference / Input / Output
GetExportJob
Command API Reference / Input / Output
GetExportJobs
Command API Reference / Input / Output
GetGcmChannel
Command API Reference / Input / Output
GetImportJob
Command API Reference / Input / Output
GetImportJobs
Command API Reference / Input / Output
GetInAppMessages
Command API Reference / Input / Output
GetInAppTemplate
Command API Reference / Input / Output
GetJourney
Command API Reference / Input / Output
GetJourneyDateRangeKpi
Command API Reference / Input / Output
GetJourneyExecutionActivityMetrics
Command API Reference / Input / Output
GetJourneyExecutionMetrics
Command API Reference / Input / Output
GetJourneyRunExecutionActivityMetrics
Command API Reference / Input / Output
GetJourneyRunExecutionMetrics
Command API Reference / Input / Output
GetJourneyRuns
Command API Reference / Input / Output
GetPushTemplate
Command API Reference / Input / Output
GetRecommenderConfiguration
Command API Reference / Input / Output
GetRecommenderConfigurations
Command API Reference / Input / Output
GetSegment
Command API Reference / Input / Output
GetSegmentExportJobs
Command API Reference / Input / Output
GetSegmentImportJobs
Command API Reference / Input / Output
GetSegments
Command API Reference / Input / Output
GetSegmentVersion
Command API Reference / Input / Output
GetSegmentVersions
Command API Reference / Input / Output
GetSmsChannel
Command API Reference / Input / Output
GetSmsTemplate
Command API Reference / Input / Output
GetUserEndpoints
Command API Reference / Input / Output
GetVoiceChannel
Command API Reference / Input / Output
GetVoiceTemplate
Command API Reference / Input / Output
ListJourneys
Command API Reference / Input / Output
ListTagsForResource
Command API Reference / Input / Output
ListTemplates
Command API Reference / Input / Output
ListTemplateVersions
Command API Reference / Input / Output
PhoneNumberValidate
Command API Reference / Input / Output
PutEvents
Command API Reference / Input / Output
PutEventStream
Command API Reference / Input / Output
RemoveAttributes
Command API Reference / Input / Output
SendMessages
Command API Reference / Input / Output
SendOTPMessage
Command API Reference / Input / Output
SendUsersMessages
Command API Reference / Input / Output
TagResource
Command API Reference / Input / Output
UntagResource
Command API Reference / Input / Output
UpdateAdmChannel
Command API Reference / Input / Output
UpdateApnsChannel
Command API Reference / Input / Output
UpdateApnsSandboxChannel
Command API Reference / Input / Output
UpdateApnsVoipChannel
Command API Reference / Input / Output
UpdateApnsVoipSandboxChannel
Command API Reference / Input / Output
UpdateApplicationSettings
Command API Reference / Input / Output
UpdateBaiduChannel
Command API Reference / Input / Output
UpdateCampaign
Command API Reference / Input / Output
UpdateEmailChannel
Command API Reference / Input / Output
UpdateEmailTemplate
Command API Reference / Input / Output
UpdateEndpoint
Command API Reference / Input / Output
UpdateEndpointsBatch
Command API Reference / Input / Output
UpdateGcmChannel
Command API Reference / Input / Output
UpdateInAppTemplate
Command API Reference / Input / Output
UpdateJourney
Command API Reference / Input / Output
UpdateJourneyState
Command API Reference / Input / Output
UpdatePushTemplate
Command API Reference / Input / Output
UpdateRecommenderConfiguration
Command API Reference / Input / Output
UpdateSegment
Command API Reference / Input / Output
UpdateSmsChannel
Command API Reference / Input / Output
UpdateSmsTemplate
Command API Reference / Input / Output
UpdateTemplateActiveVersion
Command API Reference / Input / Output
UpdateVoiceChannel
Command API Reference / Input / Output
UpdateVoiceTemplate
Command API Reference / Input / Output
VerifyOTPMessage
Command API Reference / Input / Output